<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Unsafe #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_GHC -funbox-strict-fields #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK hide #-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  GHC.IOPort</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) Tamar Christina 2019</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  cvs-ghc@haskell.org</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  non-portable (GHC Extensions)</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- The IOPort type. This is a facility used by the Windows IO subsystem.</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- We have strict rules with an I/O Port:</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- * writing more than once is an error</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- * reading more than once is an error</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- It gives us the ability to have one thread to block, wait for a result from</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- another thread and then being woken up. *Nothing* more.</span><span>
</span><span id="line-23"></span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- This type is very much GHC internal. It might be changed or removed without</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- notice in future releases.</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IOPort</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><span class="hs-comment">-- * IOPorts</span></span><span>
</span><span id="line-31"></span><span>          </span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier">IOPort</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOPort.html#newIOPort"><span class="hs-identifier">newIOPort</span></a></span><span>
</span><span id="line-33"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOPort.html#newEmptyIOPort"><span class="hs-identifier">newEmptyIOPort</span></a></span><span>
</span><span id="line-34"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOPort.html#readIOPort"><span class="hs-identifier">readIOPort</span></a></span><span>
</span><span id="line-35"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOPort.html#writeIOPort"><span class="hs-identifier">writeIOPort</span></a></span><span>
</span><span id="line-36"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOPort.html#doubleReadException"><span class="hs-identifier">doubleReadException</span></a></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Exception.html"><span class="hs-identifier">GHC.Exception</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Text.Show.html"><span class="hs-identifier">Text.Show</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-keyword">data</span><span> </span><span id="IOPortException"><span class="annot"><a href="GHC.IOPort.html#IOPortException"><span class="hs-identifier hs-var">IOPortException</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="IOPortException"><span class="annot"><a href="GHC.IOPort.html#IOPortException"><span class="hs-identifier hs-var">IOPortException</span></a></span></span><span> </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621679549924"><span id="local-6989586621679549926"><span id="local-6989586621679549928"><span class="annot"><span class="annottext">Int -&gt; IOPortException -&gt; ShowS
[IOPortException] -&gt; ShowS
IOPortException -&gt; String
(Int -&gt; IOPortException -&gt; ShowS)
-&gt; (IOPortException -&gt; String)
-&gt; ([IOPortException] -&gt; ShowS)
-&gt; Show IOPortException
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [IOPortException] -&gt; ShowS
$cshowList :: [IOPortException] -&gt; ShowS
show :: IOPortException -&gt; String
$cshow :: IOPortException -&gt; String
showsPrec :: Int -&gt; IOPortException -&gt; ShowS
$cshowsPrec :: Int -&gt; IOPortException -&gt; ShowS
</span><a href="GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679549915"><span id="local-6989586621679549917"><span class="annot"><a href="GHC.Exception.Type.html#Exception"><span class="hs-identifier hs-type">Exception</span></a></span><span> </span><span class="annot"><a href="GHC.IOPort.html#IOPortException"><span class="hs-identifier hs-type">IOPortException</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-46"></span><span>    </span><span id="local-6989586621679549912"><span class="annot"><span class="annottext">displayException :: IOPortException -&gt; String
</span><a href="GHC.Exception.Type.html#displayException"><span class="hs-identifier hs-var hs-var hs-var hs-var">displayException</span></a></span></span><span> </span><span class="annot"><span class="annottext">IOPortException
</span><a href="GHC.IOPort.html#IOPortException"><span class="hs-identifier hs-var">IOPortException</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IOPortException&quot;</span></span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="annot"><a href="GHC.IOPort.html#doubleReadException"><span class="hs-identifier hs-type">doubleReadException</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span>
</span><span id="line-50"></span><span id="doubleReadException"><span class="annot"><span class="annottext">doubleReadException :: SomeException
</span><a href="GHC.IOPort.html#doubleReadException"><span class="hs-identifier hs-var hs-var">doubleReadException</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOPortException -&gt; SomeException
forall e. Exception e =&gt; e -&gt; SomeException
</span><a href="GHC.Exception.Type.html#toException"><span class="hs-identifier hs-var">toException</span></a></span><span> </span><span class="annot"><span class="annottext">IOPortException
</span><a href="GHC.IOPort.html#IOPortException"><span class="hs-identifier hs-var">IOPortException</span></a></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="hs-keyword">data</span><span> </span><span id="IOPort"><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-var">IOPort</span></a></span></span><span> </span><span id="local-6989586621679549957"><span class="annot"><a href="#local-6989586621679549957"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="IOPort"><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-var">IOPort</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#IOPort%23"><span class="hs-identifier hs-type">IOPort#</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#RealWorld"><span class="hs-identifier hs-type">RealWorld</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549957"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-comment">{- ^
An 'IOPort' is a synchronising variable, used
for communication between concurrent threads, where one of the threads is
controlled by an external state. e.g. by an I/O action that is serviced by the
runtime.  It can be thought of as a box, which may be empty or full.

It is mostly similar to the behavior of 'Control.Concurrent.MVar.MVar'
except 'writeIOPort' doesn't block if the variable is full and the GC
won't forcibly release the lock if it thinks
there's a deadlock.

The properties of IOPorts are:
* Writing to an empty IOPort will not block.
* Writing to an full  IOPort will not block. It might throw an exception.
* Reading from an IOPort for the second time might throw an exception.
* Reading from a full IOPort will not block, return the value and empty the port.
* Reading from an empty IOPort will block until a write.
* Reusing an IOPort (that is, reading or writing twice) is not supported
  and might throw an exception. Even if reads and writes are
  interleaved.

This type is very much GHC internal. It might be changed or removed without
notice in future releases.

-}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-80"></span><span id="local-6989586621679549966"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679549906"><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549966"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-81"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span id="local-6989586621679549904"><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549904"><span class="hs-identifier hs-var">ioport1#</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679549903"><span class="annot"><span class="annottext">== :: IOPort a -&gt; IOPort a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">==</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span id="local-6989586621679549902"><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549902"><span class="hs-identifier hs-var">ioport2#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-82"></span><span>            </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#isTrue%23"><span class="hs-identifier hs-var">isTrue#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOPort# RealWorld a -&gt; IOPort# RealWorld a -&gt; Int#
forall d a. IOPort# d a -&gt; IOPort# d a -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#sameIOPort%23"><span class="hs-identifier hs-var">sameIOPort#</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549904"><span class="hs-identifier hs-var">ioport1#</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549902"><span class="hs-identifier hs-var">ioport2#</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-comment">-- |Create an 'IOPort' which is initially empty.</span><span>
</span><span id="line-87"></span><span id="local-6989586621679549963"><span class="annot"><a href="GHC.IOPort.html#newEmptyIOPort"><span class="hs-identifier hs-type">newEmptyIOPort</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549963"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-88"></span><span id="newEmptyIOPort"><span class="annot"><span class="annottext">newEmptyIOPort :: forall a. IO (IOPort a)
</span><a href="GHC.IOPort.html#newEmptyIOPort"><span class="hs-identifier hs-var hs-var">newEmptyIOPort</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; (# State# RealWorld, IOPort a #))
-&gt; IO (IOPort a)
forall a. (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a
</span><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-var">IO</span></a></span><span> </span><span class="annot"><span class="annottext">((State# RealWorld -&gt; (# State# RealWorld, IOPort a #))
 -&gt; IO (IOPort a))
-&gt; (State# RealWorld -&gt; (# State# RealWorld, IOPort a #))
-&gt; IO (IOPort a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679549900"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549900"><span class="hs-identifier hs-var">s#</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-89"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, IOPort# RealWorld a #)
forall d a. State# d -&gt; (# State# d, IOPort# d a #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#newIOPort%23"><span class="hs-identifier hs-var">newIOPort#</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549900"><span class="hs-identifier hs-var">s#</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-90"></span><span>         </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679549899"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549899"><span class="hs-identifier hs-var">s2#</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679549898"><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549898"><span class="hs-identifier hs-var">svar#</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549899"><span class="hs-identifier hs-var">s2#</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a -&gt; IOPort a
forall a. IOPort# RealWorld a -&gt; IOPort a
</span><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-var">IOPort</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549898"><span class="hs-identifier hs-var">svar#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="hs-comment">-- |Create an 'IOPort' which contains the supplied value.</span><span>
</span><span id="line-93"></span><span id="local-6989586621679549956"><span class="annot"><a href="GHC.IOPort.html#newIOPort"><span class="hs-identifier hs-type">newIOPort</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679549956"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549956"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-94"></span><span id="newIOPort"><span class="annot"><span class="annottext">newIOPort :: forall a. a -&gt; IO (IOPort a)
</span><a href="GHC.IOPort.html#newIOPort"><span class="hs-identifier hs-var hs-var">newIOPort</span></a></span></span><span> </span><span id="local-6989586621679549893"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679549893"><span class="hs-identifier hs-var">value</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-95"></span><span>    </span><span class="annot"><span class="annottext">IO (IOPort a)
forall a. IO (IOPort a)
</span><a href="GHC.IOPort.html#newEmptyIOPort"><span class="hs-identifier hs-var">newEmptyIOPort</span></a></span><span>        </span><span class="annot"><span class="annottext">IO (IOPort a) -&gt; (IOPort a -&gt; IO (IOPort a)) -&gt; IO (IOPort a)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679549892"><span class="annot"><span class="annottext">IOPort a
</span><a href="#local-6989586621679549892"><span class="hs-identifier hs-var">ioport</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-96"></span><span>    </span><span class="annot"><span class="annottext">IOPort a -&gt; a -&gt; IO Bool
forall a. IOPort a -&gt; a -&gt; IO Bool
</span><a href="GHC.IOPort.html#writeIOPort"><span class="hs-identifier hs-var">writeIOPort</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort a
</span><a href="#local-6989586621679549892"><span class="hs-identifier hs-var">ioport</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679549893"><span class="hs-identifier hs-var">value</span></a></span><span>  </span><span class="annot"><span class="annottext">IO Bool -&gt; IO (IOPort a) -&gt; IO (IOPort a)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span>
</span><span id="line-97"></span><span>    </span><span class="annot"><span class="annottext">IOPort a -&gt; IO (IOPort a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort a
</span><a href="#local-6989586621679549892"><span class="hs-identifier hs-var">ioport</span></a></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">-- |Atomically read the the contents of the 'IOPort'.  If the 'IOPort' is</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- currently empty, 'readIOPort' will wait until it is full.  After a</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- 'readIOPort', the 'IOPort' is left empty.</span><span>
</span><span id="line-102"></span><span class="hs-comment">--</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- There is one important property of 'readIOPort':</span><span>
</span><span id="line-104"></span><span class="hs-comment">--</span><span>
</span><span id="line-105"></span><span class="hs-comment">--   * Only a single threads can be blocked on an 'IOPort'.</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span id="local-6989586621679549947"><span class="annot"><a href="GHC.IOPort.html#readIOPort"><span class="hs-identifier hs-type">readIOPort</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549947"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549947"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-108"></span><span id="readIOPort"><span class="annot"><span class="annottext">readIOPort :: forall a. IOPort a -&gt; IO a
</span><a href="GHC.IOPort.html#readIOPort"><span class="hs-identifier hs-var hs-var">readIOPort</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span id="local-6989586621679549891"><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549891"><span class="hs-identifier hs-var">ioport#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a
forall a. (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a
</span><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-var">IO</span></a></span><span> </span><span class="annot"><span class="annottext">((State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a)
-&gt; (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679549890"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549890"><span class="hs-identifier hs-var">s#</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
-&gt; State# RealWorld -&gt; (# State# RealWorld, a #)
forall d a. IOPort# d a -&gt; State# d -&gt; (# State# d, a #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#readIOPort%23"><span class="hs-identifier hs-var">readIOPort#</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549891"><span class="hs-identifier hs-var">ioport#</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549890"><span class="hs-identifier hs-var">s#</span></a></span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span class="hs-comment">-- |Put a value into an 'IOPort'.  If the 'IOPort' is currently full,</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- 'writeIOPort' will throw an exception.</span><span>
</span><span id="line-112"></span><span class="hs-comment">--</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- There is one important property of 'writeIOPort':</span><span>
</span><span id="line-114"></span><span class="hs-comment">--</span><span>
</span><span id="line-115"></span><span class="hs-comment">--   * Only a single thread can be blocked on an 'IOPort'.</span><span>
</span><span id="line-116"></span><span class="hs-comment">--</span><span>
</span><span id="line-117"></span><span id="local-6989586621679549951"><span class="annot"><a href="GHC.IOPort.html#writeIOPort"><span class="hs-identifier hs-type">writeIOPort</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679549951"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679549951"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span></span><span>
</span><span id="line-118"></span><span id="writeIOPort"><span class="annot"><span class="annottext">writeIOPort :: forall a. IOPort a -&gt; a -&gt; IO Bool
</span><a href="GHC.IOPort.html#writeIOPort"><span class="hs-identifier hs-var hs-var">writeIOPort</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOPort.html#IOPort"><span class="hs-identifier hs-type">IOPort</span></a></span><span> </span><span id="local-6989586621679549889"><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549889"><span class="hs-identifier hs-var">ioport#</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679549888"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679549888"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(State# RealWorld -&gt; (# State# RealWorld, Bool #)) -&gt; IO Bool
forall a. (State# RealWorld -&gt; (# State# RealWorld, a #)) -&gt; IO a
</span><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-var">IO</span></a></span><span> </span><span class="annot"><span class="annottext">((State# RealWorld -&gt; (# State# RealWorld, Bool #)) -&gt; IO Bool)
-&gt; (State# RealWorld -&gt; (# State# RealWorld, Bool #)) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679549887"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549887"><span class="hs-identifier hs-var">s#</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-119"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
-&gt; a -&gt; State# RealWorld -&gt; (# State# RealWorld, Int# #)
forall d a. IOPort# d a -&gt; a -&gt; State# d -&gt; (# State# d, Int# #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#writeIOPort%23"><span class="hs-identifier hs-var">writeIOPort#</span></a></span><span> </span><span class="annot"><span class="annottext">IOPort# RealWorld a
</span><a href="#local-6989586621679549889"><span class="hs-identifier hs-var">ioport#</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679549888"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549887"><span class="hs-identifier hs-var">s#</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-120"></span><span>        </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679549886"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549886"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549886"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-121"></span><span>        </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679549885"><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549885"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="#local-6989586621679549885"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span></pre></body></html>